<script setup lang="ts">
import { ref, unref, watch } from 'vue'
// import { propTypes } from '@/utils/propTypes'
import { ElInputNumber } from 'element-plus'
const props = defineProps({
  // modelValue: propTypes.any.def('')
  modelValue: {
    type: [Number, String],
    default: undefined
  }
})
// 输入框的值
const valueRef = ref(Number(props.modelValue))

watch(
  () => props.modelValue,
  (val: number | string) => {
    if (val === unref(valueRef)) return
    valueRef.value = Number(val)
  }
)
const emit = defineEmits(['update:modelValue'])
// 监听
watch(
  () => valueRef.value,
  (val: number) => {
    emit('update:modelValue', val)
  }
)
</script>

<template>
  <el-input-number v-bind="$attrs" v-model="valueRef" />
</template>
